﻿<%@page import="java.util.List"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="Pragma" content="no-cache">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<title>创建会议</title>
		<link rel="stylesheet" type="text/css" href="${base}/css/date.css" />
		<link rel="stylesheet" type="text/css" href="${base}/css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="${base}/css/font-awesome-4.7.0/css/font-awesome.css" />
		<%
		    String appid  = (String)request.getAttribute("appId");
		    String nonceStr  = (String)request.getAttribute("nonceStr");
		    String timestamp = (String)request.getAttribute("timestamp");//10
		    String signature = (String)request.getAttribute("signature");
		    String userid=(String)request.getAttribute("loginuser");		  
		    
		%>

		<script type="text/javascript">
			function stops() {
				return false;
			}
			document.oncontextmenu = stops;
		</script>
		<style type="text/css">
			.weui-panel:before,
			.weui-panel:after {
				border: 0px;
			}
			
			#details:after {
				content: "";
				clear: both;
				display: table
			}
			
			.left {
				margin-top: 1em;
			}
			
			.left>a {
				height: 2em;
				width: 100%;
				margin-bottom: 5px;
				padding: 0;
				border-radius: 3px;
				background: #10AEFF;
			}
			
			.left>a i {
				height: 100%;
				width: 100%;
				font-size: 20px;
				line-height: 2em;
				color: #fff;
			}
			
			.weui-cells {
				margin-top: 5px;
			}
			
			.weui-media-box {
				padding: 3px 15px;
				position: relative;
			}
			
			.weui-tabbar__item.weui-bar__item--on .weui-tabbar__label {
				color: #04BE02;
			}
			
			.weui-flex {
				background: #fff;
			}
			
			#create {
				position: absolute;
				bottom: 5px;
				margin-left: 1%;
				width: 98%;
			}
			
			.weui-icon-warn {
				display: none;
			}
			
			.weui-mask,
			.weui-dialog {
				opacity: 1;
				visibility: visible;
			}
			
			.weui-dialog__bd {
				line-height: 40px
			}
			
			.drinkList {
				overflow: hidden;
			}
			
			.drinkList button {
				width: 20px;
				border: 1px solid #eee;
				background: #fff;
			}
			
			.drinkList button.minus {
				margin-left: 20px;
			}
			
			.drinkList input {
				width: 30px;
				font-size: 16px;
				text-align: center;
			}
			.weui-label i{
				margin-right: 2px;
			}
			i{
				width: 18px;
			}
		</style>
	</head>

	<body>
		<div class="page" style="background: #EEEEEE;" id="meetting_create">
			<div class="weui-cells weui-cells_form" style="margin-top: 0;">
				<div class=weui-cell>
					<div class=weui-cell__hd><label class=weui-label><i class="fa fa-meetup"></i>会议标题</label></div>
					<div class=weui-cell__bd> <input id="title" class=weui-input type=text required placeholder=输入会议标题 emptytips=会议标题不能为空> </div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd"><label for="" class="weui-label"><i class="fa fa-calendar"></i>开始日期</label></div>
					<div class="weui-cell__bd">
						<input class="weui-input" type="date" value="" placeholder="" id="date" style="font-family: initial;">
					</div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>
				<div class="weui-cell weui-cell_select weui-cell_select-after">
					<div class="weui-cell__hd">
						<label for="" class="weui-label"><i class="fa fa-clock-o"></i>时间选择</label>
					</div>
					<div class="weui-cell__bd">
						<select class="weui-select" id="hour">
							<option value="0">上午(9:00~12:00)</option>
							<option value="1">下午(14:00~18:00)</option>
							<option value="2">全天(9:00~18:00)</option>
						</select>
					</div>
				</div>
			</div>

			<div class="weui-cells">
				<div class="weui-cell">
					<div class="weui-cell__hd"><label for="" class="weui-label"><i class="fa fa-suitcase"></i>会议地点</label></div>
					<div class="weui-cell__bd">
						<input class="weui-input" type="text" value="" disabled id="roomselect">
					</div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd"><label for="" class="weui-label"><i class="fa fa-video-camera"></i>设备信息</label></div>
					<div class="weui-cell__bd">
						<span class="weui-textarea" id="device" disabled></span>
						<div class="weui-textarea-counter"></div>
					</div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>

			</div>

			<div class="weui-cells">
				<a class="weui-cell weui-cell_access" href="javascript:;" id="peo0">
					<div class="weui-cell__bd">
						<p><i class="fa fa-user-secret"></i> 主持人</p>
					</div>
					<div class="weui-cell__ft" id="count0">请选择</div>
				</a>
				<a class="weui-cell weui-cell_access" href="javascript:;" id="peo1">
					<div class="weui-cell__bd">
						<p><i class="fa fa-user"></i> 发起人</p>
					</div>
					<div class="weui-cell__ft" id="count1">已选择1人</div>
				</a>
				<a class="weui-cell weui-cell_access" href="javascript:;" id="peo2">
					<div class="weui-cell__bd">
						<p><i class="fa fa-user-plus"></i> 参与人</p>
					</div>
					<div class="weui-cell__ft" id="count2">已选择0人</div>
				</a>
				<div class=weui-cell>
					<div class=weui-cell__hd><label class=weui-label><i class="fa fa-users"></i>参会人数</label></div>
					<div class=weui-cell__bd> <input id="total" class=weui-input type=number required> </div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__bd">
						<textarea class="weui-textarea" placeholder="备注信息" rows="4" id="other"></textarea>
						<div class="weui-textarea-counter"></div>
					</div>
					<div class=weui-cell__ft> <i class=weui-icon-warn></i> </div>
				</div>
			</div>
			<div class="weui-cells">
				<div class="weui-cell weui-cell_switch">
					<div class="weui-cell__bd"><i class="fa fa-unlock-alt"></i> 是否为私密会议</div>
					<div class="weui-cell__ft">
						<input class="weui-switch" type="checkbox" id="secret">
					</div>
				</div>
				<div class="weui-cell weui-cell_select weui-cell_select-after">
					<div class="weui-cell__hd">
						<label for="" class="weui-label"><i class="fa fa-clock-o"></i>会议提醒</label>
					</div>
					<div class="weui-cell__bd">
						<select class="weui-select" name="select2" id="warn">
							<option value="0">不提醒</option>
							<option value="15">会议前15分钟</option>
							<option value="30">会议前30分钟</option>
							<option value="60">会议前1小时</option>
						</select>
					</div>
				</div>
			</div>

			<div class="weui-cells">
				<div class="weui-cell weui-cell_switch">
					<div class="weui-cell__bd"><i class="fa fa-beer"></i> 会议预订饮品选项</div>
					<div class="weui-cell__ft">
						<input class="weui-switch" type="checkbox" id="drink">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">美式滴虑</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="10" name="" id="meis" value="0" disabled />
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
						(限10杯以上)
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">奶咖</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" max="10" name="" id="naik" value="0" disabled />
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
						(不超过10杯)
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">拿铁</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="nat" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">卡布奇诺</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="kaib" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">香草拿铁</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="xiangc" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">榛果拿铁</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="zheng" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">焦糖玛奇朵</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="jiaot" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">摩卡</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="mok" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
				<div class="weui-cell drinkList">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">果汁(时令)</label>
					</div>
					<div class="weui-cell__bd">
						<button class="minus">-</button>
						<input type="text" min="0" name="" id="guoz" value="0" disabled/>
						<button class="plus">+</button>
					</div>
					<div class="weui-cell__ft">
					</div>
				</div>
			</div>

			<div class="weui-flex" id="first">
				<div class="weui-flex__item">
					<div class="placeholder">
						<a href="javascript:;" id="back_select" class="weui-btn weui-btn_default" style="margin:10px 20px;">返回</a>
					</div>
				</div>
				<div class="weui-flex__item" id="submit">
					<div class="placeholder">
						<a href="javascript:;" class="weui-btn weui-btn_primary" style="margin:10px 20px;">提交</a>
					</div>
				</div>
			</div>
			<div class="weui-flex" id="second" style="display:none">
				<div class="weui-flex__item" id="delete">
					<div class="placeholder">
						<a href="javascript:;" class="weui-btn weui-btn_warn" style="margin:10px 20px;">取消会议</a>
					</div>
				</div>
				<div class="weui-flex__item" id="update">
					<div class="placeholder">
						<a href="javascript:;" class="weui-btn weui-btn_primary" style="margin:10px 20px;">更新</a>
					</div>
				</div>
			</div>
		</div>
		<!--BEGIN dialog2-->
		<div class="js_dialog" id="iosDialog2" style="display:none">
			<div class="weui-mask"></div>
			<div class="weui-dialog">
				<div class="weui-dialog__hd"><strong class="weui-dialog__title"></strong></div>
				<div class="weui-dialog__bd"></div>
				<div class="weui-dialog__ft">
					<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" onclick="dialogHide()">确定</a>
				</div>
			</div>
		</div>
		<div class="js_dialog" id="iosDialog3" style="display:none">
            <div class="weui-mask"></div>
            <div class="weui-dialog">
                <div class="weui-dialog__hd"><strong class="weui-dialog__title">确定取消该会议</strong></div>
                <!--<div class="weui-dialog__bd">弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内</div>-->
                <div class="weui-dialog__ft">
                    <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default" onclick="dialogHide()">返回</a>
                    <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" onclick="deleteMeet()">确定</a>
                </div>
            </div>
        </div>
		<div class="js_dialog" id="iosDialog1" style="display:none">
			<div class="weui-mask"></div>
			<div class="weui-dialog">
				<div class="weui-dialog__hd"><strong class="weui-dialog__title">注意事项</strong></div>
				<div class="weui-dialog__bd">1.预订饮料需至少提前2天<br />2.取消预订必须提前一天<br />3.美式滴虑限制10杯以上<br />4.奶咖不超过10杯</div>
				<div class="weui-dialog__ft">
					<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" onclick="dialogHide()">知道了</a>
				</div>
			</div>
		</div>
		<script src="${base}/js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
		<script src="${base}/js/jquery-weui.js" type="text/javascript" charset="utf-8"></script>
		<script src="${base}/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var initiator = ['<%=userid %>'];
			var participant = []
			var zcr = [];

			function parseURL(url) {
				if(url.indexOf("?") == -1) return
				var url = url.split("?")[1];
				var res = [];
				if(url.indexOf("&") == -1) {
					var arr = url.split("=");
					res[arr[0]] = arr[1]
				} else {
					var arr = url.split("&");
					for(var i = 0; i < arr.length; i++) {
						var key = arr[i].split("=");
						res[key[0]] = key[1]
					}
				}
				return res

			}
			var url2 = location.href;
			url2 = decodeURIComponent(url2)
			var res = parseURL(url2)
			var mdata = [];
			$(".drinkList").hide()
			if(res != undefined) {
				if(res.type == "ydr") {
					$("#second").show();
					$("#first").hide();
					$("#meetting_create").show().siblings().hide();
					$.post("/meet/meetinfoQuery", { //根据会议序号查询其信息
						xh: res.xh
					}, function(data) {
						if(data.mc.device =="undefined") {
							
							$("#device").parent().parent().hide()
						}
						$("#title").val(data.mc.topic);
						$("#roomselect").val(data.mc.room);
						var date = data.mc.starttime.slice(0, 10)
						$("#date").val(date);
						if(gethour(data.mc.starttime) == "09" && gethour(data.mc.finishtime) == "12") {
							$("#hour").val(0)
						} else if(gethour(data.mc.starttime) == "14" && gethour(data.mc.finishtime) == "18") {
							$("#hour").val(1)
						} else if(gethour(data.mc.starttime) == "09" && gethour(data.mc.finishtime) == "18") {
							$("#hour").val(2)
						}
						$("#total").val(data.mc.prechr);
						$("#other").val(data.mc.meetbz);
						$('#secret')[0].checked = data.mc.isprivate;
						$("#warn").val(data.mc.isremind);
						$("#device").html(data.mc.device)
						initiator = data.mc.ydr.split(",");
						participant = data.mc.chr.split(",");
						zcr = data.mc.zcr.split(",");
						$("#count0").html(data.zcrname);
						$("#count1").html("已选择" + initiator.length + "人")
						$("#count2").html("已选择" + participant.length + "人")
						if(data.mc.isdrink==1){
							$.post("findByMeetXh",{meetxh:res.xh},function(Ddata){
								$("#drink")[0].checked=true;
								$(".drinkList").show();
								$("#meis").val(Ddata[0].meis),
								$("#naik").val(Ddata[0].naik),
								$("#nat").val(Ddata[0].nat),
								$("#kaib").val(Ddata[0].kaib),
								$("#xiangc").val(Ddata[0].xiangc),
								$("#zheng").val(Ddata[0].zheng),
								$("#jiaot").val(Ddata[0].jiaot),
								$("#mok").val(Ddata[0].mok),
								$("#guoz").val(Ddata[0].guoz)
							})
						}
					})
				} else if(res.room != undefined) {
					if(res.type == "1") {
						$("#device").parent().parent().hide()
					}
					$("#roomselect").val(res.room)
					$("#meetting_create").show().siblings().hide()
					$("#date").val(res.starttime.slice(0, 10))
					if(gethour(res.starttime) == "09" && gethour(res.finishtime) == "12") {
						$("#hour").val(0)
					} else if(gethour(res.starttime) == "14" && gethour(res.finishtime) == "18") {
						$("#hour").val(1)
					} else if(gethour(res.starttime) == "09" && gethour(res.finishtime) == "18") {
						$("#hour").val(2)
					}
					if(res.device == undefined || res.device == null) {
						res.device == ""
					}
					$("#device").html(res.device)
				}
			}

			function dialogHide() {
				$("#iosDialog2").hide()
				$("#iosDialog1").hide()
				$("#iosDialog3").hide()
			}
			wx.config({
				beta: true,
				debug: false,
				appId: '<%=appid %>',
				timestamp: '<%=timestamp %>',
				nonceStr: '<%=nonceStr %>',
				signature: '<%=signature %>',
				jsApiList: [
					'checkJsApi',
					'onMenuShareAppMessage',
					'onMenuShareWechat',
					'startRecord',
					'stopRecord',
					'onVoiceRecordEnd',
					'playVoice',
					'pauseVoice',
					'stopVoice',
					'uploadVoice',
					'downloadVoice',
					'chooseImage',
					'previewImage',
					'uploadImage',
					'downloadImage',
					'getNetworkType',
					'openLocation',
					'getLocation',
					'hideOptionMenu',
					'showOptionMenu',
					'hideMenuItems',
					'showMenuItems',
					'hideAllNonBaseMenuItem',
					'showAllNonBaseMenuItem',
					'closeWindow',
					'scanQRCode',
					'previewFile',
					'openEnterpriseChat',
					'selectEnterpriseContact',
					'onHistoryBack'
				]
			});
			wx.checkJsApi({
				jsApiList: ['openEnterpriseChat'], // 需要检测的JS接口列表，所有JS接口列表见附录2,

				success: function(res) {
					console.log(res)
				}
				// 以键值对的形式返回，可用的api值true，不可用为false

			});

			function getuser(type, arr) {
				wx.invoke("selectEnterpriseContact", {
					"fromDepartmentId": 0, // 必填，-1表示打开的通讯录从自己所在部门开始展示, 0表示从最上层开始

					"mode": "multi", // 必填，选择模式，single表示单选，multi表示多选

					"type": ["user"], // 必填，选择限制类型，指定department、user中的一个或者多个

					//					"selectedDepartmentIds": ["2", "3"], // 非必填，已选部门ID列表。用于多次选人时可重入

					"selectedUserIds": arr // 非必填，已选用户ID列表。用于多次选人时可重入

				}, function(res) {

					if(res.err_msg == "selectEnterpriseContact:ok") {
						if(type == "zcr") {
							zcr = [];
							$("#count0").html("")
						} else if(type == "ydr") {
							initiator = [];
							$("#count1").html("")
						} else if(type == "cyr") {
							participant = [];
							$("#count2").html("")
						}
						if(typeof res.result == 'string') {
							res.result = JSON.parse(res.result) //由于目前各个终端尚未完全兼容，需要开发者额外判断result类型以保证在各个终端的兼容性

						}
						var selectedDepartmentList = res.result.departmentList; // 已选的部门列表
						for(var i = 0; i < selectedDepartmentList.length; i++) {
							var department = selectedDepartmentList[i];
							var departmentId = department.id; // 已选的单个部门ID

							var departemntName = department.name; // 已选的单个部门名称

						}
						var selectedUserList = res.result.userList; // 已选的成员列表

						for(var i = 0; i < selectedUserList.length; i++) {
							var user = selectedUserList[i];
							var userId = user.id; // 已选的单个成员ID
							var userName = user.name; // 已选的单个成员名称
							if(type == "zcr") {
								zcr.push(userId)
								if(i == 0) {
									$("#count0").html(userName);
								} else {
									$("#count0").html($("#count0").html() + "," + userName);
								}
							} else if(type == "ydr") {
								initiator.push(userId)
							} else if(type == "cyr") {
								participant.push(userId);
							}
							var userAvatar = user.avatar; // 已选的单个成员头像
						}
						if(type == "ydr") {
							var html = "已选择" + selectedUserList.length + "人";
							$("#count1").html(html)
						} else if(type == "cyr") {
							var html = "已选择" + selectedUserList.length + "人";
							$("#count2").html(html)
						}
					}
					$("#total").val(zcr.length + participant.length)
				});
			}

			$("#peo0").click(function() { //调用通讯录分别选择主持人、发起人、参与人
				getuser("zcr", zcr)
			})
			$("#peo1").click(function() {
				getuser("ydr", initiator)
			})
			$("#peo2").click(function() {
				getuser("cyr", participant)
			});
			$("input").on("input", function() {
				$(this).parent().next().children().hide();
			})

			function getnum(time) {
				var a = time.slice(0, 10).split("-");
				return a[2]
			}

			function gethour(time) {
				var a = time.slice(11).split(":");
				return a[0]
			}
			$("#submit").click(function() { //提交预订信息
				var topic = $("#title").val();
				var room = $("#roomselect").val();
				if($("#hour").val() == 0) {
					var starttime = $("#date").val() + "T09:00";
					var finishtime = $("#date").val() + "T12:00";
				} else if($("#hour").val() == 1) {
					var starttime = $("#date").val() + "T14:00";
					var finishtime = $("#date").val() + "T18:00";
				} else if($("#hour").val() == 2) {
					var starttime = $("#date").val() + "T09:00";
					var finishtime = $("#date").val() + "T18:00";
				}
				
				var a = zcr.toString();
				var b = initiator.toString();
				var c = participant.toString();
				var prechr = $("#total").val();
				var bz = $("#other").val();
				var device = $("#device").html();
				var secret = $('#secret')[0].checked;
				var warn = $("#warn").val();
				var num=$("#meis").val()+$("#naik").val()+$("#nat").val()+$("#kaib").val()+$("#xiangc").val()+$("#zheng").val()+$("#jiaot").val()+$("#mok").val()+$("#guoz").val();
				if(num==0){
					var isdrink=0
				}else{
					var isdrink=1
				}
				var drink={
					meis:$("#meis").val(),
					naik:$("#naik").val(),
					nat:$("#nat").val(),
					kaib:$("#kaib").val(),
					xiangc:$("#xiangc").val(),
					zheng:$("#zheng").val(),
					jiaot:$("#jiaot").val(),
					mok:$("#mok").val(),
					guoz:$("#guoz").val()
				}
				if(room == "") { //判断是否选择会议室
					$("#iosDialog2 .weui-dialog__title").html("未选择会议室！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				}
				if(topic == "") {
					$("#iosDialog2 .weui-dialog__title").html("未输入会议标题！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(a == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择主持人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(b == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择发起人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(c == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择参与人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				}
				$.post("${base}/meet/submit", {
					topic: topic,
					room: room,
					starttime: starttime,
					finishtime: finishtime,
					zcr: a,
					ydr: b,
					chr: c,
					prechr: prechr,
					bz: bz,
					device: device,
					isprivate: secret,
					isremind: warn,
					drink:drink,
					isdrink:isdrink
				}, function(data) {
					if(data.res == true) {
						$.confirm({
							title: '预订成功',
							text: '继续创建?',
							onOK: function() {
								location.href = "${base}/meet/meetroomnav"
							},
							onCancel: function() {
								location.href = "${base}/meet/rcnav?time=" + starttime
							}
						});
					} else {
						$("#iosDialog2 .weui-dialog__title").html("预订失败！")
						$("#iosDialog2 .weui-dialog__bd").html(data.base)
						$("#iosDialog2").show()
					}
				})
			})
			$("#delete").click(function() { //删除会议室
				$("#iosDialog3").show()
			})
			function deleteMeet(){
				$("#iosDialog3").hide()
				$.post("deletemeet", {
					xh: res.xh
				}, function(data) {
					if(data.res == true) {
						$("#iosDialog2 .weui-dialog__title").html("取消成功！")
						$("#iosDialog2 .weui-dialog__bd").hide()
						$("#iosDialog2").show()
						setTimeout(function(){
							location.href = "${base}/meet/meetroomnav"
						},1500)
						
					} else {
						$("#iosDialog2 .weui-dialog__title").html("取消失败！")
						$("#iosDialog2 .weui-dialog__bd").html(data.base)
						$("#iosDialog2 .weui-dialog__bd").show()
						$("#iosDialog2").show()
					}
				})
			}
			$("#update").click(function() { //更新会议室
				var topic = $("#title").val();
				var room = $("#roomselect").val();
				if($("#hour").val() == 0) {
					var starttime = $("#date").val() + "T09:00";
					var finishtime = $("#date").val() + "T12:00";
				} else if($("#hour").val() == 1) {
					var starttime = $("#date").val() + "T14:00";
					var finishtime = $("#date").val() + "T18:00";
				} else if($("#hour").val() == 2) {
					var starttime = $("#date").val() + "T09:00";
					var finishtime = $("#date").val() + "T18:00";
				}
				var a = zcr.toString();
				var b = initiator.toString();
				var c = participant.toString();
				var prechr = $("#total").val();
				var bz = $("#other").val();
				var device = $("#device").html();
				var secret = $('#secret')[0].checked;
				var warn = $("#warn").val();
				var num=$("#meis").val()+$("#naik").val()+$("#nat").val()+$("#kaib").val()+$("#xiangc").val()+$("#zheng").val()+$("#jiaot").val()+$("#mok").val()+$("#guoz").val();
				if(num==0){
					var isdrink=0
				}else{
					var isdrink=1
				}
				var drink={
					meis:$("#meis").val(),
					naik:$("#naik").val(),
					nat:$("#nat").val(),
					kaib:$("#kaib").val(),
					xiangc:$("#xiangc").val(),
					zheng:$("#zheng").val(),
					jiaot:$("#jiaot").val(),
					mok:$("#mok").val(),
					guoz:$("#guoz").val()
				}
				if(room == "") { //判断是否选择会议室
					$("#iosDialog2 .weui-dialog__title").html("未选择会议室！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				}
				if(topic == "") {
					$("#iosDialog2 .weui-dialog__title").html("未输入会议标题！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(a == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择主持人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(b == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择发起人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				} else if(c == "") {
					$("#iosDialog2 .weui-dialog__title").html("未选择参与人！")
					$("#iosDialog2 .weui-dialog__bd").hide()
					$("#iosDialog2").show()
					return
				}

				$.post("update", {
					xh: res.xh,
					topic: topic,
					room: room,
					starttime: starttime,
					finishtime: finishtime,
					zcr: a,
					ydr: b,
					chr: c,
					prechr: prechr,
					bz: bz,
					device: device,
					isprivate: secret,
					isremind: warn,
					drink:drink,
					isdrink:isdrink
				}, function(data) {
					if(data.res == true) {
						$("#iosDialog2 .weui-dialog__title").html("更新成功！")
						$("#iosDialog2 .weui-dialog__bd").hide()
						$("#iosDialog2").show()
						setTimeout(function(){
							history.go(-1)
						},2000)
						
					} else {
						$("#iosDialog2 .weui-dialog__title").html("更新失败！")
						$("#iosDialog2 .weui-dialog__bd").html(data.base)
						$("#iosDialog2 .weui-dialog__bd").show()
						$("#iosDialog2").show()
					}
				})
			})
			$("#drink").click(function() {
				if($(this)[0].checked) {
					$("#iosDialog1").show()
					$(".drinkList").show("slow")
				} else {
					$(".drinkList").hide("slow")
				}
			})
			$(".drinkList .minus").click(function() {
				var num = $(this).next().val();
				num--
					if(num < 0) {
						num = 0
					}
				$(this).next().val(num)

			})
			$(".drinkList .plus").click(function() {
				var num = $(this).prev().val();
				num++
				if($(this).prev().attr("id") == 'naik') {
					if(num > 10) {
						num = 10
					}
				}
				$(this).prev().val(num)
			})
		</script>

	</body>

</html>